package com.urchin.avatarhero;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

import com.urchin.avatarhero.util.SQLiteHandler;

/**********************************************************************
AvatarHero - A task management RPG Android Application
Copyright (C) 2013  Peter Clay

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/


public class SetupPrefs extends Activity {
	
	
	 @Override
	 protected void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
	     setContentView(R.layout.setup);
	     setTitle(R.string.app_name);	        
	 }

	 @Override
	 public boolean onCreateOptionsMenu(Menu menu) {
		 getMenuInflater().inflate(R.menu.setup, menu);
	     return true;
	 }
	    
	 protected void onStop() {
	  	super.onStop();
	 }
	 
	 public void setSetup(View view) {
		 EditText editText = (EditText) findViewById(R.id.edit_message);
		 String message = editText.getText().toString().trim();
		 // Get preferences
		 Prefs prefs = new Prefs();
		 prefs.setMyStringPref(getApplicationContext(),message, "char_name");
		 prefs.setMyIntPref(getApplicationContext(),(int) 0, "char_exp");
		 prefs.setMyIntPref(getApplicationContext(),(int) 1, "char_lvl");
		 prefs.setMyBoolPref(getApplicationContext(),false, "first_time");
		 
		 // Reset the quests
		 SQLiteHandler dbHandler = new SQLiteHandler(getApplicationContext());
		 dbHandler.opendb();
		 dbHandler.deleteAllQuests();
		 dbHandler.closedb();
	    
		 // Return to main screen
		 SetupPrefs.this.finish();
	 }
}
